﻿Imports System.Runtime.Serialization

<Serializable()>
Public Class GraphicsSet
    Implements ISerializable

#Region "Serialization"
    Private Sub New(info As SerializationInfo, context As StreamingContext)
        Dim version As Integer = info.GetInt32("version")

        If version >= 1 Then
            Graphics = info.GetValue(Of Image)("graphics")
            TileSize = info.GetValue(Of Size)("tileSize")
            PageSize = info.GetValue(Of Size)("pageSize")
            Id = info.GetString("id")
        End If

        If version >= 2 Then
            Path = info.GetString("path")
        Else
            Path = Id & ".png"
        End If
    End Sub


    Public Sub GetObjectData(info As SerializationInfo, context As StreamingContext) Implements ISerializable.GetObjectData
        info.AddValue("version", 2)

        'Version 1 data
        info.AddValue("graphics", Graphics)
        info.AddValue("tileSize", TileSize)
        info.AddValue("pageSize", PageSize)
        info.AddValue("id", Id)

        'Version 2 data
        info.AddValue("path", Path)

    End Sub
#End Region

    Public Property Graphics As Image
    Public Property TileSize As Size
    Public Property PageSize As Size
    Public Property Id As String
    Public Property Path As String

    Public Sub New(id As String)
        Me.Id = id
    End Sub
End Class
